package com.teacherprofile.manage.controller;

import java.util.List;

import com.teacherprofile.common.utils.StringUtils;
import com.teacherprofile.manage.domain.dto.EducationalBackgroundExportDTO;
import jakarta.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.teacherprofile.common.annotation.Log;
import com.teacherprofile.common.core.controller.BaseController;
import com.teacherprofile.common.core.domain.AjaxResult;
import com.teacherprofile.common.enums.BusinessType;
import com.teacherprofile.common.domain.EducationalBackground;
import com.teacherprofile.manage.service.IEducationalBackgroundService;
import com.teacherprofile.common.utils.poi.ExcelUtil;
import com.teacherprofile.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 教育背景景Controller
 *
 * @author qvtu
 * @date 2025-05-17
 */
@Api(tags = "教育背景景")
@RestController
@RequestMapping("/manage/background")
public class EducationalBackgroundController extends BaseController {
    @Autowired
    private IEducationalBackgroundService educationalBackgroundService;

    /**
     * 查询教育背景景列表
     */
    @ApiOperation(value = "查询教育背景景列表")
    @PreAuthorize("@ss.hasPermi('manage:background:list')")
    @GetMapping("/list")
    public TableDataInfo list(EducationalBackground educationalBackground) {
        startPage();
        List<EducationalBackground> list = educationalBackgroundService.selectEducationalBackgroundList(educationalBackground);
        return getDataTable(list);
    }

//    /**
//     * 导出教育背景景列表
//     */
//    @ApiOperation(value = "导出教育背景景列表")
//    @PreAuthorize("@ss.hasPermi('manage:background:export')")
//    @Log(title = "教育背景景", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, EducationalBackgroundExportDTO dto) {
//        List<EducationalBackground> list = educationalBackgroundService.selectEducationalBackgroundList(dto);
//        ExcelUtil<EducationalBackground> util = new ExcelUtil<EducationalBackground>(EducationalBackground.class);
//        util.exportEasyExcel(response, list, "教育背景数据", StringUtils.str2List(dto.getExportFields(), ",", true, true));
//    }

    /**
     * 获取教育背景详细信息
     */
    @ApiOperation(value = "获取教育背景详细信息")
    @PreAuthorize("@ss.hasPermi('manage:background:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(educationalBackgroundService.selectEducationalBackgroundById(id));
    }

    /**
     * 新增教育背景
     */
    @ApiOperation(value = "新增教育背景")
    @PreAuthorize("@ss.hasPermi('manage:background:add')")
    @Log(title = "教育背景", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EducationalBackground educationalBackground) {
        return toAjax(educationalBackgroundService.insertEducationalBackground(educationalBackground));
    }

    /**
     * 修改教育背景
     */
    @ApiOperation(value = "修改教育背景")
    @PreAuthorize("@ss.hasPermi('manage:background:edit')")
    @Log(title = "教育背景", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EducationalBackground educationalBackground) {
        return toAjax(educationalBackgroundService.updateEducationalBackground(educationalBackground));
    }

    /**
     * 删除教育背景
     */
    @ApiOperation("删除教育背景")
    @PreAuthorize("@ss.hasPermi('manage:background:remove')")
    @Log(title = "教育背景", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(educationalBackgroundService.deleteEducationalBackgroundByIds(ids));
    }

//    /**
//     * 导入教育背景
//     *
//     * @param file
//     * @return
//     * @throws Exception
//     */
//    @ApiOperation("导入教育背景")
//    @Log(title = "导入管理", businessType = BusinessType.IMPORT)
//    @PreAuthorize("@ss.hasPermi('system:background:import')")
//    @PostMapping("/importData")
//    public AjaxResult importData(MultipartFile file) throws Exception {
//        ExcelUtil<EducationalBackground> util = new ExcelUtil<EducationalBackground>(EducationalBackground.class);
//        List<EducationalBackground> educationalBackground = util.importEasyExcel(file.getInputStream());
//        String message = educationalBackgroundService.importData(educationalBackground);
//        return success(message);
//    }

//    /**
//     * 审批
//     */
//    @ApiOperation(value = "教育背景审批")
//    @PreAuthorize("@ss.hasPermi('manage:background:check')")
//    @Log(title = "教育背景", businessType = BusinessType.UPDATE)
//    @PutMapping("/check")
//    public AjaxResult check(@RequestBody EducationalBackground educationalBackground) {
//        return toAjax(educationalBackgroundService.check(educationalBackground));
//    }
}
